//Ta Duc Viet
//xau dinh chuoi overlap
#include <iostream>
#include <string>
using namespace std;
int overlap ( char *, char *);//Tra ve do dai chuoi overlap
int main(){
	char str_1[80], str_2[80];

	cin.getline (str_1, 80);

	cin.getline (str_2, 80);
	cout << endl << overlap ( str_1, str_2) << endl;
	system("pause");
	return 0;
}
int overlap ( char *str_1, char *str_2){
	int len_1, len_2;
	char s_1[80], s_2[80];
	strcpy(s_1, str_1);
	strcpy(s_2, str_2);
	char *temp_1, *temp_2;
	temp_1 = s_1;
	temp_2 = s_2;
	len_1 = strlen (str_1);
	len_2 = strlen (str_2);
	int i, j;
	i = j = 0;
	//////////////////////////////////////////////
	// str_1 chua tien to, str_2 chua hau to
	while (len_2 - len_1 > 0){ // str_2 dai hon str_1, xoa phan dau str_2
			temp_2++;
			len_1 = strlen(temp_1);
			len_2 = strlen(temp_2);
		}
	while (len_2 - len_1 < 0){ // str_1 dai hon str_2, xoa phan cuoi str_1
			len_1 = len_1 - 1;
			temp_1 [len_1] = '\0'; // Xoa ki tu cuoi temp_1
			len_1 = strlen(temp_1);
			len_2 = strlen(temp_2);
		}
		// Cat 2 chuoi bang nhau
	int len = len_1;
	for ( i = 0; strcmp( temp_1, temp_2) != 0 && i < len; i++){ 	
		len_1 = len_1 - 1;
		temp_1 [len_1] = '\0'; // Xoa ki tu cuoi temp_1
		temp_2++; // xoa ki tu dau temp_2
	}
	int over_1 = strlen(temp_1);
	////////////////////////////////////////////////
	strcpy(s_1, str_1);
	strcpy(s_2, str_2);
	temp_1 = s_1;
	temp_2 = s_2;
	len_1 = strlen (str_1);
	len_2 = strlen (str_2);
	///////////////////////////////////////////////////
	// str_1 chua hau to, str_2 chua tien to
	while (len_2 - len_1 > 0){ // str_2 dai hon str_1, xoa phan cuoi str_2
			len_2 = len_2 - 1;
			temp_2 [len_2] = '\0'; // Xoa ki tu cuoi temp_1
			len_1 = strlen(temp_1);
			len_2 = strlen(temp_2);
		}
	while (len_2 - len_1 < 0){ // str_1 dai hon str_2, xoa phan dau str_1
			temp_1++;
			len_1 = strlen(temp_1);
			len_2 = strlen(temp_2);
		}
		// Cat 2 chuoi bang nhau
	len = len_1;
	for ( j = 0; strcmp( temp_1, temp_2) != 0 && j < len; j++){ 
		len_2 = len_2 - 1;
		temp_2 [len_2] = '\0'; // Xoa ki tu cuoi temp_2
		temp_1++; // xoa ki tu dau temp_1
	}
	int over_2 = strlen (temp_2);
	////////////////////////////////////////////////////////////
	if ( over_1 >= over_2) return over_1;
	else return over_2;
}
